<?php

namespace Patrol\Controller;

use Think\Controller;

class SendController extends Controller {

    public function send() {
        header("Content-Type: text/html;charset=utf-8");
        $c['code'] = file_get_contents("php://input");
        $c['ctime'] = date('Y-m-d H:i:s');
        M('cs')->add($c);
        $securityData = json_decode($c['code']);
        $securityData = json_decode($securityData->securityData);

        $data = json_decode($c, true);
        $methodCode = $data['methodCode'];
        switch ($securityData->methodCode) {
            //登录
            case 'userLogin':
                $object = new \Patrol\Controller\LoginController();
                $object->index($securityData);
                break;
            //二维码签到接口
            case 'ScanQRCode':
                $object = new \Patrol\Controller\ScanQRCodeController();
                $object->index($securityData);
                break;
            //问题反馈接口
            case 'SubmitProblem':
                $object = new \Patrol\Controller\SubmitProblemController();
                $object->index($securityData);
                break;
            //设备列表接口
            case 'DeviceListCode':
                $object = new \Patrol\Controller\DeviceListCodeController();
                $object->index($securityData);
                break;

            default:
                die('{"result":false,"message":"错误提交"}');
                break;
        }
//
    }
     public function receive() {
        header("Content-Type: text/html;charset=utf-8");
        $c['code'] = file_get_contents("php://input");
        $c['ctime'] = date('Y-m-d H:i:s');
        M('cs')->add($c);
        $securityData = json_decode($c['code']);
        $securityData = json_decode($securityData->securityData);

        $data = json_decode($c, true);
        $methodCode = $data['methodCode'];
        switch ($securityData->methodCode) {
            //登录
            case 'userLogin':
                $object = new \Patrol\Controller\LoginController();
                $object->index($securityData);
                break;

            default:
                die('{"result":false,"message":"错误提交"}');
                break;
        }
//
    }
    public function cs() {
        $object = new \Patrol\Controller\LoginController();
        $object->index($securityData);
    }
    public function upload() {
        if(empty($_FILES)) die('{"result":false,"message":"错误提交"}');
        $result = shangchuan('image', 'Patrol');
        if($result){
            echo '{"result":true,"message":"success","imagePath":"'.$result.'"}';

        }else{
            echo '{"result":false,"message":"fail","imagePath":"'.$result.'"}';
        }
    }

}
